package leetcode.code0530;

import leetcode.helper.tree.TreeNode;

public class Solution {

	int last, ans;

	public int getMinimumDifference(TreeNode root) {
		ans = Integer.MAX_VALUE;
		last = -100000;
		f(root);
		return ans;
	}

	private void f(TreeNode root) {
		if (root == null)
			return;
		f(root.left);
		ans = Math.min(ans, root.val - last);
		last = root.val;
		f(root.right);
	}
}
